<template>
  <button @click="increase(-1)">-</button>
  <button @click="increase(1)">+</button>
  <input type="number" :value="currentValue" @input="changeValue">
</template>

<script>
  export default {
    name: "NumberInput",
    porps: {
      value: {
        type: Number,
        default: 0,
        require: true
      }
    },
    data() {
      return {
        currentValue: this.value
      }
    },
    watch: {
      value(newValue) {
        this.currentValue = newValue
      }
    },
    methods: {
      changeValue(e) {
        this.currentValue = parseInt(e.target.value)
        this.$emit('input', this.currentValue)
      },
      increase(value) {
        this.currentValue += value
        this.$emit('input', this.currentValue)
      }
    }
  }
</script>
